/*******************************************************************************
 * Filename	: omx_component_ImageDecoderJpeg.h													       
 *
 * Description	: openmax Jpeg Decoder Component														   
 *
 * Notes		:                                       
 *
 *--------------------------------------------------------------------------------
 * Change History: 
 *
 *--------------------------------------------------------------------------------
 *          
 *  1.0.0	2008-10-6 yuyiwei
 *
 *******************************************************************************/

#ifndef _OMX_COMPONENT_IMAGEDECODERJPEG_
#define _OMX_COMPONENT_IMAGEDECODERJPEG_

/*----------------- include file declaration ----------------------------*/
#include <stdlib.h>
#include <string.h>

#include <OMX_Types.h>
#include <OMX_Component.h>
#include <OMX_Core.h>

#include "omx_osa.h"
#include "omx_base_filter.h"

/*----------------- external variable declaration ----------------------------*/

/*----------------- file-local constant and type definition ------------------*/
typedef OMX_U32 HANDLE;

/*----------------- file-local macro definition ------------------------------*/
#define IMAGE_DEC_BASE_NAME "OMX.dt.image.decoder"
#define IMAGE_DEC_JPEG_NAME "OMX.dt.image.decoder.jpeg"
#define IMAGE_DEC_JPEG_ROLE "image.decoder.jpeg"
/*----------------- file-local variables definition --------------------------*/
/** Jpeg decoder component port structure.
 */
DERIVEDCLASS(omx_jpegdec_component_PortType, omx_base_PortType)
#define omx_jpegdec_component_PortType_FIELDS omx_base_PortType_FIELDS \
/** @param sImageParam Domain specific (image) OpenMAX port parameter */ \
OMX_IMAGE_PARAM_PORTFORMATTYPE sImageParam;
ENDCLASS(omx_jpegdec_component_PortType)

/** jpegdec component private structure.
 */
DERIVEDCLASS(omx_jpegdec_component_PrivateType, omx_base_filter_PrivateType)
#define omx_jpegdec_component_PrivateType_FIELDS omx_base_filter_PrivateType_FIELDS \
    /** @param stream structure pointer to mad stream structure */ \
    OMX_U32 nImgWidth, nImgHeight; \
	/* current stream reading state */ \
	OMX_S32 nJpegInState;	\
	/* current stream writing state */ \
	OMX_S32 nJpegOutState;	\
	/* current stream reading position */ \
	OMX_U32 nJpegStreamPos;	\
    /** @param semaphore for mad decoder access syncrhonization */\
    omx_sem* JpegSyncSem; \
    /** @param jpegdecReady boolean flag that is true when the image coded has been initialized */ \
    OMX_BOOL JpegReady;    \
    /** @param image_coding_type Field that indicate the supported image format of image decoder */ \
    OMX_U32 image_coding_type;  \
    /** @param pTempBuffer Field that used for image decoding */ \
    OMX_U8 *pTempBuffer; \
    /** @param temporary_buffer temporary buffer used for image decoding */ \
    OMX_BUFFERHEADERTYPE *temporary_buffer_in;\
	/** @param output temporary_buffer temporary buffer used for image decoding */ \
	OMX_U8 *pTempOutBuffer; \
	/** @param temporary_buffer_out temporary buffer used for image decoding */ \
	OMX_BUFFERHEADERTYPE *temporary_buffer_out;
ENDCLASS(omx_jpegdec_component_PrivateType)
	
/*----------------- file-local function prototype declaration ----------------*/


/*----------------- function definition --------------------------------------*/
/* Component private entry points declaration */
OMX_ERRORTYPE omx_ImageDecoderJpeg_Constructor(OMX_COMPONENTTYPE *openmaxStandComp, OMX_STRING cComponentName);
OMX_ERRORTYPE omx_ImageDecoderJpeg_Destructor(OMX_COMPONENTTYPE *openmaxStandComp);
OMX_ERRORTYPE omx_ImageDecoderJpeg_Init(OMX_COMPONENTTYPE *openmaxStandComp);
OMX_ERRORTYPE omx_ImageDecoderJpeg_Deinit(OMX_COMPONENTTYPE *openmaxStandComp);
OMX_ERRORTYPE omx_ImageDecoderJpeg_MessageHandler(OMX_COMPONENTTYPE *, internalRequestMessageType*);

void omx_ImageDecoderJpeg_BufferMgmtCallback(OMX_COMPONENTTYPE *openmaxStandComp, OMX_BUFFERHEADERTYPE *inputbuffer, OMX_BUFFERHEADERTYPE *outputbuffer);

OMX_ERRORTYPE omx_ImageDecoderJpeg_GetParameter(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nParamIndex, OMX_INOUT OMX_PTR ComponentParameterStructure);

OMX_ERRORTYPE omx_ImageDecoderJpeg_SetParameter(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nParamIndex, OMX_IN OMX_PTR ComponentParameterStructure);

void omx_ImageDecoderJpeg_SetInternalParameters(OMX_COMPONENTTYPE *openmaxStandComp);

#endif

/*------------------------------- End of file --------------------------------*/
